﻿<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
             xmlns:system="clr-namespace:System;assembly=mscorlib"
             xmlns:viewmodel="clr-namespace:Flowers.Data.ViewModel;assembly=Flowers.Data"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:flowers="clr-namespace:Flowers"
             mc:Ignorable="d"
             x:Class="Flowers.App">

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Styles/MiscStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <viewmodel:ViewModelLocator x:Key="Locator"
                                        d:IsDataSource="True" />

            <flowers:LocalizedStrings
                x:Key="LocalizedStrings" />

            <system:String x:Key="ApplicationName">FLOWERS</system:String>

            <SolidColorBrush x:Key="HighlightBrush"
                             Color="#FFFA28D4" />
            
            <Style x:Key="IconStyle"
                   TargetType="Image">
                <Setter Property="Stretch"
                        Value="None" />
                <Setter Property="HorizontalAlignment"
                        Value="Right" />
                <Setter Property="VerticalAlignment"
                        Value="Top" />
                <Setter Property="Margin"
                        Value="0,20,24,0" />
                <Setter Property="Source"
                        Value="Assets/Icon.png" />
            </Style>

            <Style x:Key="ListBoxItemStyle"
                   TargetType="ListBoxItem">
                <Setter Property="Background"
                        Value="Transparent" />
                <Setter Property="BorderThickness"
                        Value="0" />
                <Setter Property="BorderBrush"
                        Value="Transparent" />
                <Setter Property="Padding"
                        Value="0" />
                <Setter Property="HorizontalContentAlignment"
                        Value="Left" />
                <Setter Property="VerticalContentAlignment"
                        Value="Top" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBoxItem">
                            <Border x:Name="LayoutRoot"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Background="{TemplateBinding Background}"
                                    HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalAlignment}">

                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal" />
                                        <VisualState x:Name="MouseOver" />
                                        <VisualState x:Name="Disabled">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                                               Storyboard.TargetName="LayoutRoot">
                                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                                            Value="{StaticResource TransparentBrush}" />
                                                </ObjectAnimationUsingKeyFrames>
                                                <DoubleAnimation Duration="0"
                                                                 To=".5"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Storyboard.TargetName="ContentContainer" />
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="SelectionStates">
                                        <VisualState x:Name="Unselected" />
                                        <VisualState x:Name="Selected">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                                               Storyboard.TargetName="ContentContainer">
                                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                                            Value="{StaticResource PhoneAccentBrush}" />
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>

                                <ContentControl x:Name="ContentContainer"
                                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                                Content="{TemplateBinding Content}"
                                                Foreground="{TemplateBinding Foreground}"
                                                Margin="{TemplateBinding Padding}"
                                                VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                HorizontalContentAlignment="Stretch" />
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
        <shell:PhoneApplicationService Launching="Application_Launching"
                                       Closing="Application_Closing"
                                       Activated="Application_Activated"
                                       Deactivated="Application_Deactivated" />
    </Application.ApplicationLifetimeObjects>

</Application>